import {
  Body,
  Controller,
  Delete,
  Get,
  HttpStatus,
  Param,
  Post,
  Put,
  Query,
  Res,
} from '@nestjs/common';
import { UserService } from './user.service';
import { Response } from 'express';
import { User } from './user.decorator';

@Controller('/users')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Get()
  getAge(@Query() query: any): string {
    return '';
  }

  @Post()
  getName(@Body() body: any): string {
    return '';
  }

  @Get(':name')
  getHello(@Param('name') name: string = ''): string {
    return this.userService.getHello(name);
  }

  @Put(':id')
  update(@Param('id') id: string, @Body() updateUserInfo: any) {
    return ``;
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return 'success';
  }

  @Post()
  create(@Res() res: Response) {
    res.status(1).send();
  }

  @Get()
  findAll(@Res({ passthrough: true }) res: Response) {
    res.status(HttpStatus.OK).json([]);
    return [];
  }

  @Get()
  findOne(@User('firstName') firstName: string) {
    console.log(`Hello ${firstName}`);
  }
}
